package com.epidemic.project.system.jiaoliu.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.epidemic.project.system.jiaoliu.domain.SysJiaoLiu;
import com.epidemic.project.system.jiaoliu.service.ISysJiaoLiuService;
import com.epidemic.framework.web.controller.BaseController;
import org.springframework.stereotype.Controller;
import com.epidemic.framework.web.domain.AjaxResult;
import com.epidemic.common.utils.poi.ExcelUtil;
import com.epidemic.framework.web.page.TableDataInfo;

/**
 * 交流沟通Controller
 *
 * @author sys
 * @date 2023-02-01
 */
@Controller
@RequestMapping("/system/jiaoliu")
public class SysJiaoLiuController extends BaseController
{
    private String prefix = "system/jiaoliu";

    @Autowired
    private ISysJiaoLiuService sysJiaoLiuService;

    @RequiresPermissions("system:jiaoliu:view")
    @GetMapping()
    public String jiaoliu()
    {
        return prefix + "/jiaoliu";
    }

    /**
     * 查询交流沟通列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysJiaoLiu sysJiaoLiu)
    {
        startPage();
        List<SysJiaoLiu> list = sysJiaoLiuService.selectSysJiaoLiuList(sysJiaoLiu);
        return getDataTable(list);
    }

    /**
     * 导出交流沟通列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysJiaoLiu sysJiaoLiu)
    {
        List<SysJiaoLiu> list = sysJiaoLiuService.selectSysJiaoLiuList(sysJiaoLiu);
        ExcelUtil<SysJiaoLiu> util = new ExcelUtil<SysJiaoLiu>(SysJiaoLiu.class);
        return util.exportExcel(list, "jiaoliu");
    }

    /**
     * 新增交流沟通
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存交流沟通
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysJiaoLiu sysJiaoLiu)
    {
        return toAjax(sysJiaoLiuService.insertSysJiaoLiu(sysJiaoLiu));
    }

    /**
     * 修改交流沟通
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysJiaoLiu sysJiaoLiu = sysJiaoLiuService.selectSysJiaoLiuById(id);
        mmap.put("sysJiaoLiu", sysJiaoLiu);
        return prefix + "/edit";
    }

    /**
     * 修改保存交流沟通
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysJiaoLiu sysJiaoLiu)
    {
        return toAjax(sysJiaoLiuService.updateSysJiaoLiu(sysJiaoLiu));
    }

    /**
     * 删除交流沟通
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysJiaoLiuService.deleteSysJiaoLiuByIds(ids));
    }
}
